package com.xyzwps.server.paimon.ui.mvc

import com.xyzwps.server.paimon.app.dto.LoginInput
import com.xyzwps.server.paimon.app.dto.LoginSendVcodeInput
import com.xyzwps.server.paimon.app.dto.Me
import com.xyzwps.server.paimon.app.LoginAppService
import com.xyzwps.server.paimon.ui.HttpResponse
import io.swagger.v3.oas.annotations.tags.Tag
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.*

@Tag(name = "User Login")
@RestController
@RequestMapping(Apis.BASE + "/login")
class LoginController(private val loginAppService: LoginAppService) {

    @PostMapping("/send-vcode")
    fun sendVcode(@RequestBody @Valid input: LoginSendVcodeInput): HttpResponse<String> {
        return HttpResponse(loginAppService.sendVcode(input))
    }

    @PostMapping
    fun login(@RequestBody @Valid input: LoginInput): HttpResponse<Me> {
        return HttpResponse(loginAppService.login(input))
    }
}
